package com.lanou.fooddemo.dao;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by dllo on 2015/8/13.
 */
public class FoodDatabaseHelper extends SQLiteOpenHelper {
    private final String LOG_TAG = "FoodDatabaseHelper";
    private static final String DATABASE_NAME = "food";
    private static final int DATABASE_VERSION = 1;
    /**
     * 通知表名
     */
    public static final String DATABASE_TABLE_NAME_NOTICE = "notice";
    public static final String CLOUMN_NAME_TITLE = "title";
    public static final String CLOUMN_NAME_CONTENT = "content";
    private static final String SQL_CREATE_TABLE_NOTICE = "create table " + DATABASE_TABLE_NAME_NOTICE + " ("
            + "_id integer primary key autoincrement,"
            + CLOUMN_NAME_TITLE + " varchar(100),"
            + CLOUMN_NAME_CONTENT + " varchar(255)" + ")";

    public static final String DATABASE_TABLE_NAME_BASKET = "basket";
    public static final String CLOUMN_NAME_USER_ICON_URL = "user_icon_url";
    public static final String CLOUMN_NAME_USER_NAME = "user_name";
    public static final String CLOUMN_NAME_USER_SIGN = "user_sign";
    public static final String CLOUMN_NAME_FOOD_URL = "food_url";
    public static final String CLOUMN_NAME_PLACE = "place";
    public static final String CLOUMN_NAME_FOOD_CONTENT = "content";
    private static final String SQL_CREATE_TABLE_BASKET = "create table " + DATABASE_TABLE_NAME_BASKET + " ("
            + "_id integer primary key autoincrement,"
            + CLOUMN_NAME_USER_ICON_URL + " varchar(100),"
            + CLOUMN_NAME_USER_NAME + " varchar(100),"
            + CLOUMN_NAME_USER_SIGN + " varchar(100),"
            + CLOUMN_NAME_FOOD_URL + " varchar(100),"
            + CLOUMN_NAME_PLACE + " varchar(100),"
            + CLOUMN_NAME_FOOD_CONTENT + " varchar(100)" + ")";

    public FoodDatabaseHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        //创建通知表
        db.execSQL(SQL_CREATE_TABLE_NOTICE);
        //创建篮子表
        db.execSQL(SQL_CREATE_TABLE_BASKET);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
